package com.qinghuan.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Auther: qinghuan
 * @Date: 2022/3/5 21:47
 * @Description:
 * 属性category 的 @Resource(name = "c") 和 @Autowired  和 放在setCategory上面的 @Autowired 意义相同，都是关联两个类
 */
@Component("p")
public class Product {

    private int id;
    private String name = "product 1";
//    @Autowired
    @Resource(name = "c")
    private Category category;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Category getCategory() {
        return category;
    }

    //和放在上面一样
//    @Autowired
    public void setCategory(Category category) {
        this.category = category;
    }
}
